<template>
	<view v-if="showPage">
		<web-view :src="urls"></web-view>
		
	</view>
</template>

<script>
	import Auth from '@/utils/auth';
	import Util from '@/utils/util';
	import Alert from '@/utils/alert';
	import Api from '@/utils/api';
	import Rest from '@/utils/rest';
	export default {
		data() {
			return {
				urls:'',
				user_id: 0,
				showPage: false
			}
		},
		onLoad(opt) {
			// uni.clearStorageSync();
			this.user_id = opt? opt.pid: 0
			uni.setStorageSync("invite_key", this.user_id)
			
		},
		onShow() {
			this.getUser();
		},
		addPhone(phone){
			Rest.post(Api.ZHUIGE_Index_Wxphone, {
				'phone':phone
			}).then(res => {
				if(res.code!=0){
					console.log(res);
				}
				
			});
		},
		methods: {
			getUser() {
				
				// if(!Auth.getUser()) {
				// 	uni.navigateTo({
				// 	    url: '/pages/login/login',
				// 	});
				// }	
				// 	return
				// }
				var _this = this
				

				if(Auth.getUser()) {
					_this.showPage = true
					_this.urls= `https://program.qdlearn.cn/ma?pid=${uni.getStorageSync('invite_key')}&user_id=${Auth.getUser().user_id}`;
				} else {
					Util.openLink('/pages/login/login');
				}
				
			}
		}
	}
</script>

<style>

</style>
